//
//  SubscribeTableViewCell.m
//  项目A_百思不得姐
//
//  Created by wudongyang on 16/5/24.
//  Copyright © 2016年 wudongyang. All rights reserved.
//

#import "SubscribeTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation SubscribeTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self carteSubViews];
    }
    return self;
}

-(void)carteSubViews{

    self.headImageV = [[UIImageView alloc] init];
    self.headImageV.backgroundColor = [UIColor yellowColor];
    self.headImageV.layer.masksToBounds = YES;
    self.headImageV.layer.cornerRadius = 10;
    [self.contentView addSubview:self.headImageV];
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.nameLabel];
    
    self.numberLabel = [[UILabel alloc] init];
    self.numberLabel.backgroundColor = [UIColor clearColor];
    self.numberLabel.textColor = DSRGBA(124, 124, 124, 1);
    self.numberLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.numberLabel];
    
    
    self.numLabel = [[UILabel alloc] init];
    self.numLabel.backgroundColor = [UIColor clearColor];
    self.numLabel.font = [UIFont systemFontOfSize:12];
    self.numLabel.text = @"总帖数";
    self.numLabel.textColor = DSRGBA(124, 124, 124, 1);
    [self.contentView addSubview:self.numLabel];
    
    self.postLabel = [[UILabel alloc] init];
    self.postLabel.backgroundColor = [UIColor clearColor];
    self.postLabel.font = [UIFont systemFontOfSize:12];
    self.postLabel.textColor = DSRGBA(186, 61, 43, 1);
    [self.contentView addSubview:self.postLabel];
    
    
    self.bigView = [[BaseUIView alloc] init];
//    self.bigView.backgroundColor = DSRGBA(223, 223, 223, 1);
    [self.contentView addSubview:self.bigView];
    
    self.xView = [[BaseUIView alloc] init];
//    self.xView.backgroundColor = DSRGBA(223, 223, 223, 1);
    [self.contentView addSubview:self.xView];
    
    self.SubscribeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.SubscribeButton.backgroundColor = [UIColor clearColor];
    [self.SubscribeButton setTitle:@"+订阅" forState:UIControlStateNormal];
    [self.SubscribeButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    self.SubscribeButton.layer.borderWidth = 0.5;
    self.SubscribeButton.layer.borderColor =  [DSRGBA(96, 96, 96, 1) CGColor];
    self.SubscribeButton.layer.masksToBounds = YES;
    self.SubscribeButton.layer.cornerRadius = 4;
    [self.contentView addSubview:self.SubscribeButton];

    [self.SubscribeButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.headImageV.frame = CGRectMake(15, 15, 53, 53);
    self.nameLabel.frame = CGRectMake(80, 15, 100, 27);
    self.numberLabel.frame = CGRectMake(80, 45, 100, 20);
    self.numLabel.frame = CGRectMake(200, 45, 40, 20);
    self.postLabel.frame = CGRectMake(240, 45, 80, 20);
    self.bigView.frame = CGRectMake(0, 79, self.contentView.frame.size.width, 1);
    self.xView.frame = CGRectMake(190, 45, 1, 20);
    self.SubscribeButton.frame = CGRectMake(335, 25, 50, 25);

}
-(void)setSubModel:(SubscribeModel *)subModel{
    _subModel = subModel;
    [self.headImageV sd_setImageWithURL:[NSURL URLWithString:_subModel.image_list] placeholderImage:[UIImage imageNamed:@"tou"]];
    self.nameLabel.text = subModel.theme_name;
    NSString *number = [NSString stringWithFormat:@"%@人订阅",subModel.sub_number];
    self.numberLabel.text = number;
    NSString *num = [NSString stringWithFormat:@"%@",subModel.post_num];
    self.postLabel.text = num;
    


}




-(void)buttonAction:(UIButton *)button{
    DSLog(@"订阅按钮点击方法");

    self.SubscribeBlock(button);
    
    
}










@end
